package com.example.myapplication;

import androidx.appcompat.app.AppCompatActivity;

import android.animation.Animator;
import android.animation.AnimatorListenerAdapter;
import android.animation.ObjectAnimator;
import android.animation.ValueAnimator;
import android.os.Bundle;
import android.util.Log;
import android.widget.TextView;

public class PropertyAnimationActivity extends AppCompatActivity {

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_property_animation);

        ValueAnimator valueAnimator =  ValueAnimator.ofFloat(0,1);
        valueAnimator.setDuration(2000);
        valueAnimator.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() {
            @Override
            public void onAnimationUpdate(ValueAnimator animation) {
                 float value = (float) animation.getAnimatedValue();
//                Log.e("TAG", "onAnimationUpdate: "+value );
            }
        });

        valueAnimator.start();
        TextView textView = findViewById(R.id.property_textView);
        ObjectAnimator objectAnimator = ObjectAnimator.ofFloat(textView,"alpha",0,1);
        objectAnimator.setDuration(4000);
        objectAnimator.start();
        objectAnimator.addListener(new Animator.AnimatorListener() {
            @Override
            public void onAnimationStart(Animator animation) {
                Log.e("TAG", "onAnimationStart: =============开始1" );
            }

            @Override
            public void onAnimationEnd(Animator animation) {
                Log.e("TAG", "onAnimationStart: =============结束" );
            }

            @Override
            public void onAnimationCancel(Animator animation) {
                Log.e("TAG", "onAnimationStart: =============取消" );
            }

            @Override
            public void onAnimationRepeat(Animator animation) {
                Log.e("TAG", "onAnimationStart: =============重复" );
            }
        });
        ///
        objectAnimator.addListener(new AnimatorListenerAdapter() {
            @Override
            public void onAnimationResume(Animator animation) {
                super.onAnimationResume(animation);
                Log.e("TAG", "onAnimationStart: =============开始2" );
            }
        });
    }
}